<html>
<head>
<script src="../editor/Narcissus.js"></script>
<script src="../editor/NjsCompiler.js"></script>
<script src="../editor/NjsScriptWriter.js"></script>
<script src="../editor/NjsRuntime.js"></script>
<script>
NjsRuntime.createXmlHttp = function() {
    var http = null;
	try{ http = new XMLHttpRequest(); }catch(e){}
	if (!http) try{ http = new ActiveXObject('Msxml2.XMLHTTP') }catch(e){}
	if (!http) try{ http = new ActiveXObject('Microsoft.XMLHTTP') }catch(e){}
	if (!http) try{ http = new ActiveXObject('Msxml2.XMLHTTP.4.0') }catch(e){}
	if (!http) throw new Error("XmlHTTP not available");
	return http;
}


function load(file) {
	window.eval(readFile(file));
}
function readFile(file) {
	var http = NjsRuntime.createXmlHttp();
	http.open('GET', file, false);
	try {
		http.send(null);
		return http.responseText;
	} catch(e) {
		return null;
	}
}
function snarf(file) {
	return readFile(file);
}
function print(text) {
	document.getElementById("results").innerHTML += String(text).replace(/\n/g, "<br>") + "<br>";
}
function test(desc, method) {
	try {
		method();
	} catch(ex) {
		if(ex.message) {
			print("FAILED: " + desc + ": " + ex.message);
		} else {
			print("FAILED: " + desc);
		}
		return;
	}

	print("passed: " + desc);
}
function start() {
	load("test_compiler.js");
	load("test_runtime.js");
}
</script>
</head>
<body onload="start()">
<pre id="results">
</pre>
</body>
</html>